﻿<MudChipSet @bind-SelectedValue="_selectedValue" @bind-SelectedValues="_selectedValues" SelectionMode="@SelectionMode">
    <MudChip Value="@("Milk")" />
    <MudChip Value="@("Eggs")" />
    <MudChip Value="@("Soap")" />
    <MudChip Value="@("Corn flakes")" />
    <MudChip Value="@("Salad")" />
    <MudChip Value="@("Apples")" />
    <MudChip Value="@("Red wine")" />
</MudChipSet>

<div class="selected-value">
    <MudText>@_selectedValue</MudText>
</div>
<div class="selected-values">
    @if (_selectedValues is { Count: > 0 }) {
        <MudText>@string.Join(", ", _selectedValues)</MudText>
    }
    else {
        <MudText>Nothing selected</MudText>
    }
</div>

@code
{
    [Parameter]
    public SelectionMode SelectionMode { get; set; } = SelectionMode.ToggleSelection;

    [Parameter]
    public string? InitialValue { get; set; }

    private string? _selectedValue;
    private IReadOnlyCollection<string>? _selectedValues;

    protected override void OnInitialized()
    {
        base.OnInitialized();
        _selectedValue = InitialValue;
    }
}